Completed
Push — master ( fa76b5...b46f0e )
by Mathieu
21s queued 11s
created

GetMonthlyFairCalendarAction.index   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 1
1
import {Controller, Inject, UseGuards, Query, Get} from '@nestjs/common';
2
import {AuthGuard} from '@nestjs/passport';
3
import {ApiTags, ApiBearerAuth, ApiOperation} from '@nestjs/swagger';
4
import {IQueryBus} from 'src/Application/IQueryBus';
5
import {GetMonthlyFairCalendarQuery} from 'src/Application/FairCalendar/Query/GetMonthlyFairCalendarQuery';
6
import {MonthlyEventsDTO} from '../DTO/MonthlyEventsDTO';
7
import {Roles} from 'src/Infrastructure/HumanResource/User/Decorator/Roles';
8
import {UserRole} from 'src/Domain/HumanResource/User/User.entity';
9
import {RolesGuard} from 'src/Infrastructure/HumanResource/User/Security/RolesGuard';
10
11
@Controller('faircalendar')
12
@ApiTags('FairCalendar')
13
@ApiBearerAuth()
14
@UseGuards(AuthGuard('bearer'), RolesGuard)
15
export class GetMonthlyFairCalendarAction {
16
  constructor(
17
    @Inject('IQueryBus')
18
    private readonly queryBus: IQueryBus
19
  ) {}
20
21
  @Get()
22
  @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE)
23
  @ApiOperation({summary: 'Get monthly faircalendar by user'})
24
  public async index(@Query() dto: MonthlyEventsDTO) {
25
    return await this.queryBus.execute(
26
      new GetMonthlyFairCalendarQuery(new Date(dto.date), dto.userId)
27
    );
28
  }
29
}
30